package com.sample.action;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.sample.action.form.MbBillForm;
import com.sample.javabean.MbBill;
import com.sample.util.Pager;

/**
 * @version 1.0
 * @author Administrator
 *
 */
public class MbBillAction extends BaseAction {
	private final static Log log = LogFactory.getLog(MbBillAction.class);
	private Pager<MbBill> pageList;

	private MbBill mbBill = new MbBill();
	private MbBillForm mbBillForm = new MbBillForm();
	private String persNumber;

	/**
	 * 添加
	 * @return
	 * @throws Exception
	 */
	public String inputMbBill() throws Exception {

		return "inputMbBill";
	}

	public String save() throws Exception {
		try {
			log.info("保存慢病证信息");
			// mbBillForm属性接值，由struts2框架自动完成属性值注入
			if (mbBillForm != null) {
				MbBill mbBill = new MbBill();
				// 将mbBillForm中的属性值一一赋予mbbill的对应的属性。
				mbBill.setPersNumber(mbBillForm.getPersNumber());
				mbBill.setCardNo(mbBillForm.getCardNo());
				mbBill.setPersName(mbBillForm.getPersName());
				mbBill.setIllname(mbBillForm.getIllname());
				mbBill.setStartday(mbBillForm.getStartday());
				mbBill.setEndday(mbBillForm.getEndday());

				// 调用add方法
				mbBill.add();
			}
			return SUCCESS;
		} catch (Exception e) {
			e.printStackTrace();

		}
		return "inputMbBill";
	}
/**
 * 查询
 * @return
 * @throws Exception
 */
	public String list() throws Exception {
		MbBill mbBillModel = new MbBill();
		pageList = mbBillModel.list(page, size, mbBillForm);
		return "listMbBill";
	}
/**
 * 删除
 * @return
 * @throws Exception
 */
	public String del() throws Exception {
		try {
			if (mbBillForm != null) {
				mbBill.setPersNumber(persNumber);
				mbBill.delMbBill();
			}
			return SUCCESS;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}
/**
 * 编辑
 * @return
 * @throws Exception
 */
	public String editMbBill() throws Exception {
		try {
			mbBill.setPersNumber(persNumber);
			mbBill.load();
			return "editMbBill";
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public String edit() throws Exception {
		try {
			if (mbBillForm != null) {
				mbBill.setPersNumber(mbBillForm.getPersNumber());
				mbBill.setCardNo(mbBillForm.getCardNo());
				mbBill.setPersName(mbBillForm.getPersName());
				mbBill.setIllname(mbBillForm.getIllname());
				mbBill.setStartday(mbBillForm.getStartday());
				mbBill.setEndday(mbBillForm.getEndday());
				mbBill.editMbBill();
			}
			return SUCCESS;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}
	/**
	 * 
	 * @return
	 */
	
	public Pager<MbBill> getPageList() {
		return pageList;
	}

	public void setPageList(Pager<MbBill> pageList) {
		this.pageList = pageList;
	}

	public MbBill getMbBill() {
		return mbBill;
	}

	public void setMbBill(MbBill mbBill) {
		this.mbBill = mbBill;
	}

	public MbBillForm getMbBillForm() {
		return mbBillForm;
	}

	public void setMbBillForm(MbBillForm mbBillForm) {
		this.mbBillForm = mbBillForm;
	}

	public String getPersNumber() {
		return persNumber;
	}

	public void setPersNumber(String persNumber) {
		this.persNumber = persNumber;
	}

}